package com.caioweb.osa.conversores;

import javax.faces.bean.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.inject.Inject;
import javax.persistence.EntityManager;

import com.caioweb.osa.dao.ClienteDAO;
import com.caioweb.osa.mb.GeraScriptBean;
import com.caioweb.osa.modelo.Cliente;

@FacesConverter("conversorcliente")
@RequestScoped
public class ConversorCliente implements Converter{
	@Inject
	private GeraScriptBean bean;
	@Inject
	ClienteDAO dao;
	
	

	@Override
	public Object getAsObject(FacesContext context, UIComponent ui, String sigla) {
		Cliente cliente = dao.procuraPorSigla(sigla);
		return cliente;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent ui, Object o) {
		Cliente cliente = new Cliente();
		cliente = (Cliente)  o;
		return cliente.getSigla();
	}



}
